package com.zhengtoudai.ui.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.zhengtoudai.R;
import com.zhengtoudai.ui.bean.TenderRecord;
import com.zhengtoudai.util.Tool;
import com.zhengtoudai.view.recyclerview.RecyclerViewAdapter;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * 投资记录适配器
 * author:xiejingwen
 */
public class InvestmentRecordAdapter extends RecyclerViewAdapter<InvestmentRecordAdapter.ViewHolder,TenderRecord.DataListEntity> {
    private String mType;

    public InvestmentRecordAdapter(String type){
        mType=type;
    }
    @Override
    public ViewHolder mOnCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item_investment_record, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void mOnBindViewHolder(ViewHolder holder, int position) {
        holder.tvName.setText(data.get(position).getEncryptName());
        if (mType.equals("borrowId")){
            holder.tvMoney.setText("¥"+Tool.toDivAccount2(data.get(position).getTenderAmount()));
            holder.tvDate.setText(data.get(position).getTenderAddtime());
        }else if (mType.equals("transId")){
            holder.tvMoney.setText("¥"+Tool.toDivAccount2(data.get(position).getAuctionMoney()));
            holder.tvDate.setText(data.get(position).getCreateTime());
        }
    }



    static class ViewHolder extends RecyclerView.ViewHolder {
        @Bind(R.id.tv_name)
        TextView tvName;
        @Bind(R.id.tv_date)
        TextView tvDate;
        @Bind(R.id.tv_money)
        TextView tvMoney;

        ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }
}
